package ru.digitanoise.dnnotificationapi.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ru.digitanoise.dnnotificationapi.model.dto.RequestSendCode;
import ru.digitanoise.dnnotificationapi.service.MailService;
import ru.digitanoise.dnutils.controller.AbstractController;

@RestController
@RequestMapping("/dn/mail/api/v1")
@RequiredArgsConstructor
public class MailController extends AbstractController {

    private final MailService mailService;

    @PostMapping("/send/code")
    public ResponseEntity<Void> sendActiveMail(
            @RequestBody RequestSendCode requestSendCode
    ) {
        logRequest(requestSendCode);

        mailService.send(requestSendCode);

        return ResponseEntity.ok().build();
    }
}
